<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户管理</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <!--axios-->
  <script type="text/javascript" src="../../js/axios.js"></script>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="../../js/api.js"></script>
  <link rel="stylesheet" href="../../layui/css/layui.css">
  <script type="text/javascript" src="../../layui/layui.js"></script>
  <script>
    $(function (){
      //页面进入时的加载事件
      load(1,5,"","","","","","0");
      // 省、市的下拉菜单事件
      addressMenuInit($("#country"),$("#city"))
      //查询按钮触发的事件
      $("#subcustom").click(function (){
        window.event.returnValue=false;
        company=$("#company").val();
        customName=$("#customname").val();
        province=$("#country").val();
        city=$("#city").val();
        statu=$("#st").val();
        service=$("#ser").val();
        load(1,5,company,customName,province,city,statu,service)
        layui.use('layer', function(){
          var layer = layui.layer;
          layer.msg("查询成功！",{icon:1})
        });
      })
    })

    function load(currentpage,rows,company,customName,province,city,statu,service){
      var url="http://121.37.227.40:8000/"
      axios({
        url:url+'marketing/marketingPage',
        method:"POST",
        data:{
        },
        params:{
          currentPage: currentpage,
          rows: rows,
          company:company,
          customName:customName,
          province:province,
          city:city,
          status:statu,
          service:service
        },
        dataType:"JSON"
      }).then(function (rel) {

        let lis='<thead>\n' +
                '        <tr>\n' +
                '          <th>序号</th>\n' +
                '          <th>客户姓名</th>\n' +
                '          <th>性别</th>\n' +
                '          <th>联系电话</th>\n' +
                '          <th>所属公司</th>\n' +
                '          <th>所属区域</th>\n' +
                '          <th>状态</th>\n' +
                '          <th>创建时间</th>\n' +
                '          <th>创建人</th>\n' +
                '          <th>分配时间</th>\n' +
                '          <th>客服人员</th>\n' +
                '          <th>操作</th>\n' +
                '        </tr>\n' +
                '      </thead>'
        lis+='<tbody>';
        rel = rel.data;
        let li
        for (let i=0;i<rel.resultData.list.length;i++){
          let data=rel.resultData.list[i];
          let sex=data.sex;
          if(data.sex==1){
            sex = "男";
          }else if(data.sex==2){
            sex = "女";
          }
          let status=data.status;
          if(data.status==1){
            status = "可用";
          }else if(data.status==2){
            status = "不可用";
          }
          if (data.status==1){
          li+='<tr>\n' +
                  '          <td>' + ((i + 1) +((currentpage-1)*rows))+ '</td>\n' +
                  '          <td>'+data.customName+'</td>\n' +
                  '          <td>'+sex+'</td>\n' +
                  '          <td>'+data.telephone+'</td>\n' +
                  '          <td>'+data.company+'</td>\n' +
                  '          <td>'+data.province.pName+''+data.city.cName+'</td>\n' +
                  '          <td>'+status+'</td>\n' +
                  '          <td>'+data.createTime+'</td>\n' +
                  '          <td>'+data.creator.uName+'</td>\n' +
                  '          <td>'+data.distracTime+'</td>\n' +
                  '          <td>'+data.serviceUser.uName+'</td>\n' +
                  '          <td>\n' +
                  '          \t<a href="javascript:void(0)" class="tablelink" onclick="goview('+data.customId+',\''+data.province.pName+'\',\''+data.city.cName+'\')">查看详情</a>\n' +
                  '            <a href="javascript:void(0)" class="tablelink" onclick="dp('+data.customId+',\''+data.province.pName+'\',\''+data.city.cName+'\')">修改</a>\n' +
                  '            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen(\'是否确认注销此条信息？\','+data.customId+','+currentpage+','+rows+','+data.status+')">注销</a>\n' +
                  '            <a href="javascript:void(0);" class="tablelink" onclick="allottipOpen('+data.customId+','+currentpage+','+rows+')">分配</a>\n' +
                  '          </td>\n' +
                  '        </tr>';
          }else {
            li+='<tr>\n' +
                    '          <td>' + ((i + 1) +((currentpage-1)*rows))+ '</td>\n' +
                    '          <td>'+data.customName+'</td>\n' +
                    '          <td>'+sex+'</td>\n' +
                    '          <td>'+data.telephone+'</td>\n' +
                    '          <td>'+data.company+'</td>\n' +
                    '          <td>'+data.province.pName+''+data.city.cName+'</td>\n' +
                    '          <td>'+status+'</td>\n' +
                    '          <td>'+data.createTime+'</td>\n' +
                    '          <td>'+data.creator.uName+'</td>\n' +
                    '          <td>'+data.distracTime+'</td>\n' +
                    '          <td>'+data.serviceUser.uName+'</td>\n' +
                    '          <td>\n' +
                    '          \t<a href="javascript:void(0)" class="tablelink" onclick="goview('+data.customId+',\''+data.province.pName+'\',\''+data.city.cName+'\')">查看详情</a>\n' +
                    '            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen1(\'是否确认恢复此条信息？\','+data.customId+','+currentpage+','+rows+','+data.status+')">恢复</a>\n' +
                    '            <a href="javascript:void(0);" class="tablelink" onclick="allottipOpen('+data.customId+','+currentpage+','+rows+')">分配</a>\n' +
                    '          </td>\n' +
                    '        </tr>';
          }
        }
        lis+=li;
        lis+='</tbody>';
        $(".tablelist").html(lis);
        $('.tablelist tbody tr:odd').addClass('odd');

        layui.use("laypage",function (){

          var laypage=layui.laypage;
          laypage.render({
            elem:"page",
            count:rel.resultData.totalCount,
            theme: '#eb5409',
            limit:rows,
            limits:[3,5,10],
            curr:currentpage,
            layout:['prev','page','next','limit','count','skip'],
            jump:function (obj,first){
              currentpage=obj.curr
              rows=obj.limit
              if (!first){
                load(currentpage,rows,company,customName,province,city,statu,service)
              }
            }

          })
        })
      })
    }
    //点击查看详情触发事件
    function goview(customId,province,city){
      location.href="../customer/customerView.html?customid="+customId+"&province="+province+"&city="+city
    }
    //点击修改触发事件
    function dp(customId,province,city){
      location.href="../customer/customerUpdate.html?customid="+customId+"&province="+province+"&city="+city
    }
  </script>
<script type="text/javascript">

  <!-- 注销提示框 -->
function tipOpen(content,customId,currentpage,rows,status) {
	$(".tipright p").text(content);
	$("#tip").fadeIn(200);
    // 注销方法
  $("#logout").click(function (){
    var url="http://121.37.227.40:8000/"
    axios({
      url:url+'marketing/updateStatus',
      method:"POST",
      params:{
        customId:customId,
        status:status
      },
      dataType:"JSON"
    }).then(function (){
      var co=$("#company").val();
      var cu=$("#customname").val();
      var pr=$("#country").val();
      var ci=$("#city").val();
      var st=$("#st").val();
      var se=$("#ser").val();
      tipClose()
      load(currentpage,rows,co,cu,pr,ci,st,se)
      layui.use('layer', function(){
        var layer = layui.layer;
        layer.msg("注销成功",{icon:1})
      });
    })
  })

}
  // <!-- 恢复 提示框 -->
function tipOpen1(content,customId,currentpage,rows,status) {
  $(".tipright p").text(content);
  $("#tip1").fadeIn(200);
  // 恢复方法
  $("#recover").click(function (){
    var url="http://121.37.227.40:8000/"
    axios({
      url:url+'marketing/updateStatus',
      method:"POST",
      params:{
        customId:customId,
        status:status
      },
      dataType:"JSON"
    }).then(function (){
      var co=$("#company").val();
      var cu=$("#customname").val();
      var pr=$("#country").val();
      var ci=$("#city").val();
      var st=$("#st").val();
      var se=$("#ser").val();
      tipClose1()
      load(currentpage,rows,co,cu,pr,ci,st,se)
      layui.use('layer', function(){
        var layer = layui.layer;
        layer.msg("恢复成功",{icon:1})
      });
    })
  })
}

  // <!-- 注销提示框关闭-->
function tipClose() {
	$("#tip").fadeOut(200);
}
  // <!-- 恢复提示框关闭-->
function tipClose1() {
  $("#tip1").fadeOut(200);
}
function allottipOpen(customId,currentpage,rows) {
	$("#allottip").fadeIn(200);
    assignmentMenuInit($("#post"),$("#name"));
    $("#assignment").click(function (){
      var name=$("#name").val()
      var url="http://121.37.227.40:8000/"
      axios({
        url:url+'marketing/assignment',
        method:"POST",
        params:{
          serviceId:name,
          customId:customId
        },
        dataType:"JSON"
      }).then(function (){
        var co=$("#company").val();
        var cu=$("#customname").val();
        var pr=$("#country").val();
        var ci=$("#city").val();
        var st=$("#st").val();
        var se=$("#ser").val();
        allottipclose()
        load(currentpage,rows,co,cu,pr,ci,st,se)
        layui.use('layer', function(){
          var layer = layui.layer;
          layer.msg("分配成功",{icon:1})
        });
      })
    })
}
function allottipclose() {
	$("#allottip").fadeOut(200);
}
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>客户管理</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form action="" method="post">
    <ul class="tools">
      <li> 公司名称:
        <input type="text" size="12" id="company"/>
      </li>
      <li> 客户姓名:
        <input type="text" size="12" id="customname"/>
      </li>
      <li> 所属区域：
        <select id="country">
          <option>请选择省份</option>
          <option>北京</option>
          <option>江苏</option>
          <option>天津</option>
        </select>
        <select id="city">
          <option value="0">请选择城市</option>
        </select>
      </li>
      <li> 状态：
        <select id="st">
          <option value="0">请选择</option>
          <option value="1">可用</option>
          <option value="2">不可用</option>
        </select>
      </li>
      <li> 是否分配：
        <select id="ser">
          <option value="0">请选择</option>
          <option value="1">已分配</option>
          <option value="2">未分配</option>
        </select>
      </li>
      <li class="subBut" id="subcustom"><img src="../../images/t06.png" />查询</li>
      <li class="subBut" onclick="window.location.href='customerAdd.html'"><img src="../../images/t01.png" />添加</li>
    </ul>
    <table class="tablelist">
<!--      <thead>-->
<!--        <tr>-->
<!--          <th>序号</th>-->
<!--          <th>客户姓名</th>-->
<!--          <th>性别</th>-->
<!--          <th>联系电话</th>-->
<!--          <th>所属公司</th>-->
<!--          <th>所属区域</th>-->
<!--          <th>状态</th>-->
<!--          <th>创建时间</th>-->
<!--          <th>创建人</th>-->
<!--          <th>分配时间</th>-->
<!--          <th>客户人员</th>-->
<!--          <th>操作</th>-->
<!--        </tr>-->
<!--      </thead>-->
<!--      <tbody>-->
<!--        <tr>-->
<!--          <td>1</td>-->
<!--          <td>王金平</td>-->
<!--          <td>男</td>-->
<!--          <td>17370899727</td>-->
<!--          <td>阿里巴巴</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>可用</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td></td>-->
<!--          <td></td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--            <a href="customerUpdate.html" class="tablelink">修改</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('是否确认注销此条信息？')">注销</a>-->
<!--            <a href="javascript:void(0);" class="tablelink" onclick="allottipOpen()">分配</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>2</td>-->
<!--          <td>张永祥</td>-->
<!--          <td>女</td>-->
<!--          <td>17370897894</td>-->
<!--          <td>腾讯公司</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>不可用</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>关羽</td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('是否确认恢复此条信息？')">恢复</a>-->
<!--            <a href="javascript:void(0);" class="tablelink" onclick="allottipOpen()">分配</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>3</td>-->
<!--          <td>王金平</td>-->
<!--          <td>男</td>-->
<!--          <td>17370899727</td>-->
<!--          <td>阿里巴巴</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>可用</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td></td>-->
<!--          <td></td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--            <a href="customerUpdate.html" class="tablelink">修改</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('是否确认注销此条信息？')">注销</a>-->
<!--            <a href="javascript:void(0);" class="tablelink" onclick="allottipOpen()">分配</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>4</td>-->
<!--          <td>张永祥</td>-->
<!--          <td>女</td>-->
<!--          <td>17370897894</td>-->
<!--          <td>腾讯公司</td>-->
<!--          <td>江苏南京</td>-->
<!--          <td>不可用</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>管理员</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>关羽</td>-->
<!--          <td>-->
<!--          	<a href="customerView.html" class="tablelink">查看详情</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('是否确认恢复此条信息？')">恢复</a>-->
<!--            <a href="javascript:void(0);" class="tablelink" onclick="allottipOpen()">分配</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--      </tbody>-->
    </table>
    <div class="pagin" id="page">
<!--      <div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>-->
<!--      <ul class="paginList">-->
<!--        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">1</a></li>-->
<!--        <li class="paginItem current"><a href="javascript:;">2</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">3</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">4</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">5</a></li>-->
<!--        <li class="paginItem more"><a href="javascript:;">...</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">10</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>-->
<!--      </ul>-->
    </div>
  </form>
  <!-- 注销 提示框 -->
  <div id="tip" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
    <div class="tipinfo"> <span><img src="../../images/ticon.png" /></span>
      <div class="tipright">
        <p></p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" id="logout"/>
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="tipClose()" />
    </div>
  </div>
  <!-- 恢复 提示框 -->
  <div id="tip1" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose1()"></a></div>
    <div class="tipinfo"> <span><img src="../../images/ticon.png" /></span>
      <div class="tipright">
        <p></p>

        <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" id="recover" />
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="tipClose1()" />
    </div>
  </div>
  <!-- 审批提示框 -->
  <div id="allottip" class="tip">
    <div class="tiptop">
    	<span>提示信息</span><a onclick="allottipclose()"></a>
    </div>
    <div class="tipinfo1"> 
    	
        部门：
            <select class="dfselect" disabled="disabled">
            	<option>请选择</option>
                <option selected="selected">市场部</option>
                <option>采购部</option>
                <option>财务部</option>
            </select>
			<p/>
            职位：
            <select class="dfselect" id="post">
            	<option value="0">请选择</option>
                <option value="1">组长</option>
                <option value="2">组员</option>
            </select>
   			<p/>
            姓名：
            <select class="dfselect" id="name">
            	<option >请选择</option>
            </select>
			<p/>
    </div>
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" id="assignment" />
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="allottipclose()" />
    </div>
  </div>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
